package com.gperp.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gperp.common.ChanpinfenleiBaobiao;
import com.gperp.common.BaobiaoResullt;
import com.gperp.common.TimeResult;
import com.gperp.mapper.other.DailishangyueBaobiaoMapper;
import com.gperp.pojo.Result;
import com.gperp.service.BaobiaoService;

@Service
public class BaobiaoServiceImpl implements BaobiaoService {

	@Autowired
	private DailishangyueBaobiaoMapper dailishangyueBaobiaoMapper;
	
	//代理商余额报表查询
	@Override
	public Result getdailishangyuebaobiao(int page,int rows) {
		// 设置分页信息
		PageHelper.startPage(page, rows);
		// 执行查询。。
		List<BaobiaoResullt> list = dailishangyueBaobiaoMapper.getdailishangyuebaobiao();
		// 取分页结果。。
		PageInfo<BaobiaoResullt> pageInfo = new PageInfo<>(list);
		Result r = new Result();
		r.setRows(pageInfo.getList());
		r.setPageIndex(page);
		r.setTotal(pageInfo.getTotal());		
		return r;
	}
	//代理商流水报表
	@Override
	public Result dailishangliushui(int page, int rows, TimeResult condition) {
		// 设置分页信息
		PageHelper.startPage(page, rows);
		// 执行查询。。
		List<BaobiaoResullt> list = dailishangyueBaobiaoMapper.dailishangliushui(condition);
		// 取分页结果。。
		PageInfo<BaobiaoResullt> pageInfo = new PageInfo<>(list);
		Result r = new Result();
		r.setRows(pageInfo.getList());
		r.setPageIndex(page);
		r.setTotal(pageInfo.getTotal());		
		return r;
	}

	//预付款报表
	@Override
	public Result yufukuan(int page, int rows, TimeResult condition) {
			
			// 设置分页信息
			PageHelper.startPage(page, rows);
			// 执行查询。。
			List<BaobiaoResullt> list = dailishangyueBaobiaoMapper.yufukuan(condition);
			// 取分页结果。。
			PageInfo<BaobiaoResullt> pageInfo = new PageInfo<>(list);
			Result r = new Result();
			r.setRows(pageInfo.getList());
			r.setPageIndex(page);
			r.setTotal(pageInfo.getTotal());		
			return r;
	}
	//产品分类报表
	@Override
	public Result getchanpinfenlei(int page, int rows) {
		// 设置分页信息
		PageHelper.startPage(page, rows);
		// 执行查询。。
		List<ChanpinfenleiBaobiao> list = dailishangyueBaobiaoMapper.getchanpinfenlei();
		// 取分页结果。。
		PageInfo<ChanpinfenleiBaobiao> pageInfo = new PageInfo<>(list);
		Result r = new Result();
		r.setRows(pageInfo.getList());
		r.setPageIndex(page);
		r.setTotal(pageInfo.getTotal());		
		return r;
	}
	//客户消费汇总报表
	@Override
	public Result getkehubaobiao(int page, int rows) {
		// 设置分页信息
		PageHelper.startPage(page, rows);
		// 执行查询。。
		List<BaobiaoResullt> list = dailishangyueBaobiaoMapper.getkehubaobiao();
		// 取分页结果。。
		PageInfo<BaobiaoResullt> pageInfo = new PageInfo<>(list);
		Result r = new Result();
		r.setRows(pageInfo.getList());
		r.setPageIndex(page);
		r.setTotal(pageInfo.getTotal());		
		return r;
	}
	@Override
	public List<BaobiaoResullt> getdailishangyuebaobiaoDown() {	
		//下载代理商余额报表
		return dailishangyueBaobiaoMapper.getdailishangyuebaobiao();
	}
	@Override
	public List<BaobiaoResullt> getyufukuanbaobiaoDown(TimeResult condition) {
		// 下载预付款报表
		return dailishangyueBaobiaoMapper.yufukuan(condition);
	}
	@Override
	public List<BaobiaoResullt> getdailishangliushui(TimeResult condition) {
		// 下载代理商流水报表
		return dailishangyueBaobiaoMapper.dailishangliushui(condition);
	}
	@Override
	public List<ChanpinfenleiBaobiao> getchanpinfenleiDown() {
		// 下载产品分类报表
		return dailishangyueBaobiaoMapper.getchanpinfenlei();
	}
	@Override
	public List<BaobiaoResullt> getkehuDown() {
		// 下载客户消费报表
		return dailishangyueBaobiaoMapper.getkehubaobiao();
	}

}
